home *** CD-ROM | disk | FTP | other *** search
/ Programming Windows 95 with MFC / Programming Windows 95 with MFC (Microsoft Programming Series)(097-0001465)(1996).iso / CODE / Chap11 / MyWord / MainFrame.cpp next >
Encoding:
C/C++ Source or Header  |  1996-04-05  |  2.1 KB  |  86 lines

  1. //***********************************************************************
  2. //
  3. //  MainFrame.cpp
  4. //
  5. //***********************************************************************
  6.  
  7. #include <afxwin.h>
  8. #include <afxext.h>
  9. #include "Resource.h"
  10. #include "StyleBar.h"
  11. #include "MainFrame.h"
  12.  
  13. IMPLEMENT_DYNCREATE (CMainFrame, CFrameWnd)
  14.  
  15. BEGIN_MESSAGE_MAP (CMainFrame, CFrameWnd)
  16.     ON_WM_CREATE ()
  17.     ON_COMMAND_EX (ID_VIEW_STYLE_BAR, OnBarCheck)
  18.     ON_UPDATE_COMMAND_UI (ID_VIEW_STYLE_BAR, OnUpdateControlBarMenu)
  19.     ON_WM_CLOSE ()
  20. END_MESSAGE_MAP ()
  21.  
  22. int CMainFrame::OnCreate (LPCREATESTRUCT lpcs)
  23. {
  24.     if (CFrameWnd::OnCreate (lpcs) == -1)
  25.         return -1;
  26.  
  27.     EnableDocking (CBRS_ALIGN_ANY);
  28.  
  29.     if (!CreateToolBar () ||
  30.         !CreateStyleBar () ||
  31.         !CreateStatusBar ())
  32.         return -1;
  33.  
  34.     LoadBarState ("BarSettings");
  35.     return 0;
  36. }
  37.  
  38. void CMainFrame::OnClose ()
  39. {
  40.     SaveBarState ("BarSettings");
  41.     CFrameWnd::OnClose ();
  42. }
  43.  
  44. BOOL CMainFrame::CreateToolBar ()
  45. {
  46.     if (!m_wndToolBar.Create (this) ||
  47.         !m_wndToolBar.LoadToolBar (IDR_TOOLBAR))
  48.         return FALSE;
  49.  
  50.     m_wndToolBar.SetBarStyle (m_wndToolBar.GetBarStyle () |
  51.         CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  52.  
  53.     m_wndToolBar.SetWindowText ("Main");
  54.     m_wndToolBar.EnableDocking (CBRS_ALIGN_ANY);
  55.     DockControlBar (&m_wndToolBar);
  56.     return TRUE;
  57. }
  58.  
  59. BOOL CMainFrame::CreateStyleBar ()
  60. {
  61.     if (!m_wndStyleBar.Create (this, WS_CHILD | WS_VISIBLE | CBRS_TOP |
  62.         CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, IDW_STYLE_BAR))
  63.         return FALSE;
  64.  
  65.     m_wndStyleBar.SetWindowText ("Styles");
  66.     m_wndStyleBar.EnableDocking (CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM);
  67.     DockControlBar (&m_wndStyleBar);
  68.     return TRUE;
  69. }
  70.  
  71. BOOL CMainFrame::CreateStatusBar ()
  72. {
  73.     static UINT nIndicators[] = {
  74.         ID_SEPARATOR,
  75.         ID_INDICATOR_LINE,
  76.         ID_INDICATOR_CAPS,
  77.         ID_INDICATOR_NUM
  78.     };
  79.  
  80.     if (!m_wndStatusBar.Create (this))
  81.         return FALSE;
  82.  
  83.     m_wndStatusBar.SetIndicators (nIndicators, 4);
  84.     return TRUE;
  85. }
  86.